Hello Let us get a look at the following code: DxlObject dxlTest = new(); dxlTest -> "testx" = "TESTX"; Skip skpTest = addr_(dxlTest); string sTest; find(skpTest, "testx", sTest); print sTest; The print result is "TESTX". This result you will get also if you code: Skip skpTest = createString; put (skpTest, "testx", "TESTX"); DxlObject dxlTest = addr_(skpTest); string sTest = (string dxlTest->"testx"); print sTest; This trick may help you if you want to find out if a specific entry in DxlObject exists or not. You can use the find-command of the skip list. Best regards Wolfgang Wolfgang Uhr - Tue Sep 23 06:46:37 EDT 2014 |
Re: DxlObject and CreateString-Skip-Lists seems to be the same There is no point in a single DxlObject that has a variable number of unknown fields. Might as well use the Skip list instead. I assert that the vast majority arrays or spreadsheets are represented by a fixed number of columns and a variable number of rows. The characteristics you care about of a car may be "Model", "Cost", "Weight", "Mileage", and "Color" (where "Model" is the unique key). You would have 5 columns but can capture 1000s of cars. I also assert that if you have a variable number of columns then you probably have a conceptual error. Conceptually a "Skip" list represents a single Characterisic (column), where each "Key" is a single Record (row). Conceptually a "DxlObject" represents a single Record (a row), and each field a different Characteristic (column). You can represent our Car array above with 4 Skip lists, each with key "Model". Inserting, deleting, and reporting requires 4 skip "finds". You can also represent it with a variable number of DxlObjects, each with 5 Fields. I may be tempted to have only 4 fields, but also have a Skip list with key "Model" and data of "DxlObject". In this case there is a single Skip "find" but still 4 checks or assignments. -Louie |
Re: DxlObject and CreateString-Skip-Lists seems to be the same On further thought ... I guess there are times you have a finite but unknown number of characteristics. If you want to print out all the "Requirements" in alphabetical order and all their "Attributes", you have a serious problem if you really don't know ahead of time the names of all the attributes, which can be different from module to module. Doing that with an "Array" will waste too much space as you will allocate an obj-attr value cell for every object, not just those with that attribute. Doing that with a variable number of "Skip" lists is acheivable, with a "Master" skip list with KEY "AttrName" and data "Skip"; each embedded skip has KEY "ReqID" and whatever attr value for that requirement. Doing that with DxlObjects is also achievable, but you still need a Master skip list containing the names of all known attributes; KEY perhaps 'Int' the order you want them displayed, DATA 'string' AttrName. And another Skip with KEY "ReqID" and DATA "DxlObject". I notice if you retrieve a DxlObject value for a field that doesn't exist, you correctly get nothing back (instead of an error). -Louie
|
Re: DxlObject and CreateString-Skip-Lists seems to be the same llandale - Tue Sep 23 11:59:44 EDT 2014 There is no point in a single DxlObject that has a variable number of unknown fields. Might as well use the Skip list instead. I assert that the vast majority arrays or spreadsheets are represented by a fixed number of columns and a variable number of rows. The characteristics you care about of a car may be "Model", "Cost", "Weight", "Mileage", and "Color" (where "Model" is the unique key). You would have 5 columns but can capture 1000s of cars. I also assert that if you have a variable number of columns then you probably have a conceptual error. Conceptually a "Skip" list represents a single Characterisic (column), where each "Key" is a single Record (row). Conceptually a "DxlObject" represents a single Record (a row), and each field a different Characteristic (column). You can represent our Car array above with 4 Skip lists, each with key "Model". Inserting, deleting, and reporting requires 4 skip "finds". You can also represent it with a variable number of DxlObjects, each with 5 Fields. I may be tempted to have only 4 fields, but also have a Skip list with key "Model" and data of "DxlObject". In this case there is a single Skip "find" but still 4 checks or assignments. -Louie Hello Louie I mean this:
struct Something {};
Something createSomething() {
DxlObject dxlObj = new();
return (Something addr_(dxlObj))
}
void addInfo(Something something, string sInfoMessage) {
DxlObject dxlObj = (DxlObject addr_(something));
dxlObj -> "sInfoMessage" = sInfoMessage;
}
bool hasInfoEntry(Something something) {
Skip skp = (Skip addr_(something));
return (find(skp, "sInfoMessage"));
}
void deleteInfoEntry(Something something) {
Skip skp = (Skip addr_(something));
delete(skp, "sInfoMessage")
}
Something something = createSomething();
print hasInfoEntry(something) "\n"; // prints false
addInfo(something, "My Special Message");
print hasInfoEntry(something) "\n"; // prints true
deleteInfoEntry(something);
print hasInfoEntry(something) "\n"; // prints false
The base element of a struct is a DxlObject. But you can refere to it as if you have a createstring-Skip list to test if an entry for the value "sInfoMessage" is availiable or not. And you can delete this entry. Both you cannot do having one the DxlObject-Routines. Best regards Wolfgang |
Re: DxlObject and CreateString-Skip-Lists seems to be the same Wolfgang Uhr - Wed Sep 24 02:34:03 EDT 2014 Hello Louie I mean this:
struct Something {};
Something createSomething() {
DxlObject dxlObj = new();
return (Something addr_(dxlObj))
}
void addInfo(Something something, string sInfoMessage) {
DxlObject dxlObj = (DxlObject addr_(something));
dxlObj -> "sInfoMessage" = sInfoMessage;
}
bool hasInfoEntry(Something something) {
Skip skp = (Skip addr_(something));
return (find(skp, "sInfoMessage"));
}
void deleteInfoEntry(Something something) {
Skip skp = (Skip addr_(something));
delete(skp, "sInfoMessage")
}
Something something = createSomething();
print hasInfoEntry(something) "\n"; // prints false
addInfo(something, "My Special Message");
print hasInfoEntry(something) "\n"; // prints true
deleteInfoEntry(something);
print hasInfoEntry(something) "\n"; // prints false
The base element of a struct is a DxlObject. But you can refere to it as if you have a createstring-Skip list to test if an entry for the value "sInfoMessage" is availiable or not. And you can delete this entry. Both you cannot do having one the DxlObject-Routines. Best regards Wolfgang I understand. Very clever to notice that. But I was suggesting that you should not WANT to do that; since IMO conceptually DxlObject fields are ..err.. should be "columns" and Skip list Keys are ..err.. should be "rows". In my conception, you don't want to "delete" a field of a DxlObject but you may want to erase it. -Louie |
Re: DxlObject and CreateString-Skip-Lists seems to be the same llandale - Wed Sep 24 13:46:40 EDT 2014 I understand. Very clever to notice that. But I was suggesting that you should not WANT to do that; since IMO conceptually DxlObject fields are ..err.. should be "columns" and Skip list Keys are ..err.. should be "rows". In my conception, you don't want to "delete" a field of a DxlObject but you may want to erase it. -Louie I think the main usage will be some code for error-debugging. But there, sometimes it is a gread help. |